package cn.yunbamboos.rest.service.session;

import cn.hutool.core.util.StrUtil;
import cn.yunbamboos.rest.service.IRestService;
import cn.yunbamboos.rest.service.ISession;
import jakarta.servlet.http.HttpServletRequest;

/**
 * session构建着
 */
public class SessionBuilder {

    private final Session session = new Session();

    public SessionBuilder set(String key, String value) {
        if(StrUtil.isNotBlank(value)){
            this.session.set(key, value);
        }
        return this;
    }

    public SessionBuilder setRequest(HttpServletRequest request){
        session.setRequest(request);

        return this;
    }

    public SessionBuilder setService(IRestService service){
        session.setService(service);
        return this;
    }

    /**
     * 创建session
     *
     * @return {@code ISession}
     */
    public ISession build() {
        return session;
    }

}
